package com.hmall.search.pojo;

import com.hmall.common.dto.Item;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Saint.Martine
 * @since 2022/12/9 16:26
 */
@Data
@NoArgsConstructor
public class ItemDoc {
    private Long id;
    private String name;
    private Long price;//价格
    private String image;//商品图片
    private String brand;//品牌名称
    private Integer sold;//销量
    private Integer commentCount;//评论数
    private Boolean isAD;//商品状态 1：正常，2：下架
    private String category;//分类名称
    //自动补齐字段
    private List<String> suggestion = new ArrayList<>(2);

    public ItemDoc(Item item) {
        //复制属性
        BeanUtils.copyProperties(item, this);
        suggestion.add(item.getBrand());
        suggestion.add(item.getCategory());
    }


}